package com.award.model;

import java.util.Date;

import com.award.jdbc.dao.JdbcDao;

public class Winner implements Comparable<Winner> {
	private Date winTime;
	private int commodityID;
	private int winnerID;
	private String winnerName;
	private String commodityName;
	private float commodityPrice;
	private int raffleNum;

	public Winner() {
		raffleNum = 0;
	}

	public int getRaffleNum() {
		return raffleNum;
	}

	public void setRaffleNum(int raffleNum) {
		this.raffleNum = raffleNum;
	}

	public Winner(int commodityID, int winnerID) {
		JdbcDao jd = new JdbcDao();
		this.commodityID = commodityID;
		this.winnerID = winnerID;
		try {
			this.setWinnerName(jd.queryEmployeeByID(winnerID).getName());
			this.setCommodityName(jd.queryCommodityByID(commodityID)
					.getCommodityName());
			this.setCommodityPrice(jd.queryCommodityByID(commodityID)
					.getPrice());
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		this.setWinTime(new Date());
	}

	public float getCommodityPrice() {
		return commodityPrice;
	}

	public void setCommodityPrice(float commodityPrice) {
		this.commodityPrice = commodityPrice;
	}

	public Date getWinTime() {
		return winTime;
	}

	public void setWinTime(Date winTime) {
		this.winTime = winTime;
	}

	public int getCommodityID() {
		return commodityID;
	}

	public void setCommodityID(int commodityID) {
		this.commodityID = commodityID;
	}

	public int getWinnerID() {
		return winnerID;
	}

	public void setWinnerID(int winnerID) {
		this.winnerID = winnerID;
	}

	public String getWinnerName() {
		return winnerName;
	}

	public void setWinnerName(String winnerName) {
		this.winnerName = winnerName;
	}

	public String getCommodityName() {
		return commodityName;
	}

	public void setCommodityName(String commodityName) {
		this.commodityName = commodityName;
	}

	@Override
	public int compareTo(Winner o) {
		// TODO Auto-generated method stub
		return (int) (-this.commodityPrice + o.commodityPrice);
	}

}
